<!--
 * @Description: 
 * @Version: 2.0
 * @Autor: 刘世琪
 * @Date: 2021-02-01 02:51:54
 * @LastEditors: Seven
 * @LastEditTime: 2021-02-01 23:51:17
-->
<template>
    <div>
        <h1>教练详情</h1>
        <table>
            <tr>
                <td>姓名</td>
                <td>年龄</td>
                <td>性别</td>
                <td>介绍</td>
                <td>操作</td>
            </tr>
             <tr>
                <td>{{coach_list.name}}</td> 
                <td>{{coach_list.age}}</td>
                <td>{{coach_list.gender}}</td>
                <td>{{coach_list.introduce}}</td>
                <td><button @click="bus">下课</button></td>
            </tr>
        </table>

    </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            id:this.$route.query.id,
            coach_list:{},
            uid:localStorage.uid,
            base_url:'http://127.0.0.1:8000/',
        }
    },
    mounted:function(){
        this.get_coach_list()
    },
    methods: {
        get_coach_list(){
            console.log(this.id)
            axios({
                url: this.base_url + 'order/',
                params:{
                    uid:this.uid,
                    coach_id:this.id
                }
            }).then(res=>{
                console.log(res.data)
                this.coach_list = res.data.data
            })
        },
        bus(){
            console.log(this.id)
            axios({
                url: this.base_url + 'order/',
                method:'post',
                data:{
                    // uid:this.uid,
                    coach_id:this.id
                }
            }).then(res=>{
                console.log(res.data)
                this.$router.push({
                        name:"Order"
                    })
                // this.$router.push({path:"/order",query:{num_id:this.id}}) 
                alert(res.data.msg)
            })
        }

    },
    created() {

    }
}
</script>

<style>
table{
    width: 300px;
    height: 50px; 
    border: solid burlywood;
    margin: 0 auto;
    border-collapse:collapse
}
td{
    border: green solid;
    border-collapse:collapse
}
</style>
